package com.bdqn.service;

import com.bdqn.common.PageSupport;
import com.bdqn.mapper.StorageRecordMapper;
import com.bdqn.pojo.StorageRecord;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service("storageRecordService")
public class StorageRecordServiceImpl implements StorageRecordService {
    @Resource
    private StorageRecordMapper storageRecordMapper;

    @Override
    public List<StorageRecord> getPageList(StorageRecord storageRecord, PageSupport page) {
        int pageNo = (page.getCurrentPageNo() - 1) * page.getPageSize();
        return storageRecordMapper.getPageList(storageRecord, pageNo, page.getPageSize());
    }

    @Override
    public int count(StorageRecord storageRecord) {
        return storageRecordMapper.count(storageRecord);
    }

    @Override
    public StorageRecord queryId(Integer id) {
        return storageRecordMapper.queryId(id);
    }

    @Override
    public boolean update(StorageRecord storageRecord) {
        storageRecord.setUpdatedTime(new Date());
        return storageRecordMapper.update(storageRecord);
    }

    @Override
    public boolean delete(Integer id) {
        return storageRecordMapper.delete(id) == 1;
    }

    @Override
    public boolean add(StorageRecord storageRecord) {
        return storageRecordMapper.add(storageRecord) == 1;
    }
}
